class Solution {
public:
    string addStrings(string num1, string num2) {
        int n1=num1.size(),n2=num2.size();
        int i=n1-1,j=n2-1;
        int carry=0;
        string res;
        while(i>=0||j>=0)
        {
            int m1=i>=0?num1[i]-'0':0;
            int m2=j>=0?num2[j]-'0':0;
            int tmp=m1+m2+carry;
            carry=tmp/10;
            res+=to_string(tmp%10);
            i--;
            j--;
        }
        if(carry==1) res+="1";
         reverse(res.begin(),res.end());
         return res;
        
    }
};